<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>个人信息</title>
	<meta name="renderer" content="webkit">	
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">	
	<meta name="apple-mobile-web-app-status-bar-style" content="black">	
	<meta name="apple-mobile-web-app-capable" content="yes">	
	<meta name="format-detection" content="telephone=no">	
	<link rel="stylesheet" type="text/css" href="common/layui/css/layui.css" media="all">
	<link rel="stylesheet" type="text/css" href="common/bootstrap/css/bootstrap.css" media="all">
	<link rel="stylesheet" type="text/css" href="common/global.css" media="all">
	<link rel="stylesheet" type="text/css" href="css/personal.css" media="all">
	<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
</head>
<body>
<section class="layui-larry-box">
	<div class="larry-personal">
		<header class="larry-personal-tit">
			<span>修改密码</span>
		</header><!-- /header -->
		<div class="larry-personal-body clearfix changepwd">
			<form class="layui-form col-lg-4">
			 	<div class="layui-form-item">
					<label class="layui-form-label">用户名</label>
					<div class="layui-input-block">  
					  	<input type="text" name="user"  autocomplete="off"  class="layui-input layui-disabled" value="${sessionScope.session.name}" disabled="disabled" >
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">旧密码</label>
					<div class="layui-input-block">  
					  	<input type="password" name="password"   class="layui-input"><h4><span name="ts"></span></h4>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">新密码</label>
					<div class="layui-input-block">  
					  	<input type="password" name="xpassword"  autocomplete="off"  class="layui-input"  placeholder="请输入新密码">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">确认密码</label>
					<div class="layui-input-block">  
					  	<input type="password" name="qrpassword"  autocomplete="off"  class="layui-input"  placeholder="请输入确认新密码">
					</div>
				</div>
				<div>
					<div class="layui-input-block">
						<span class="layui-btn" name="updatepwd"  lay-filter="demo1">立即提交</span>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</section>
<script type="text/javascript" src="common/layui/layui.js"></script>
<script type="text/javascript">
	layui.use(['form','upload'],function(){
         var form = layui.form;
	$(function(){
		$("input[name='password']").blur(function(){
			var pwd=$("input[name='password']").val();
			var name=$("input[name='user']").val();
			$.ajax({
				type:"POST",
				dataType:"json",
				url:"../chengeAction!changePwd",
				data:{"password":pwd,"user":name},
				success:function(mag){
					if(mag==false){
						$("span[name=ts]").text("密码错误请重新输入");
						$("span[name=ts]").css("color","red");
						$("input[name='password']").val("");
					}else{
						$("span[name=ts]").text("");
					}
					
				}
			});
		});
		//修改密码
		$("span[name='updatepwd']").bind('click',function(){
			var pwd=$("input[name='password']").val();
			var name=$("input[name='user']").val();
			var xpassword=$("input[name='xpassword']").val();
			var qrpwd=$("input[name='qrpassword']").val();
			if(xpassword==qrpwd){
				$.ajax({
					type:"POST",
					dataType:"json",
					url:"../chengeAction!updatePwd",
					data:{"password":pwd,"user":name,"xpassword":xpassword},
					success:function(mag){
						if(mag){
							alert("修改成功！！！点击重新登录！");
							location.href="login.jsp";
						}else{
							alert("修改密码失败！！！");
						}
					}
				});
			}
			else{
				alert("两次密码不一致请重新输入》》》》")
			}
		});
	});
	});
</script>
</body>
</html>